<!-- pages/songs/index.vue 歌曲列表页 -->
<template>
    <Pages :current="3" class="songs">
        <view class="page-header">
            <text class="header-title">歌曲管理</text>
            <CustomButton text="创作" @click="handleAddTag" backgroundColor="#409eff" />
        </view>
        <scroll-view class="list-container" scroll-y>
            <view v-for="song in songList" :key="song.id" class="song-item" @click="navigateToDetail(song.id)">
                <view class="item-content">
                    <text class="song-title">{{ song.name }}</text>
                    <text class="song-desc">{{ song.description }}</text>
                </view>
                <uni-icons type="arrowright" size="20" color="#999" />
            </view>
        </scroll-view>
    </Pages>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue';
import { useSongStore } from '@/stores/songs';
import Pages from '@/components/pages/index.vue'
import CustomButton from '@/components/CustomButton.vue'

const songStore = useSongStore();
const songList = computed(() => songStore.songs);

const navigateToDetail = (id) => {
    uni.navigateTo({
        url: `/pages/Song/Detail?id=${id}`
    });
};

const handleAddTag = () => {
    uni.navigateTo({
        url: `/pages/Test/Coze`
    });
}

onMounted(() => {
    songStore.fetchSongs();
})
</script>

<style lang="scss" scoped>
.songs {
    // height: 100vh;
    box-sizing: border-box;
    padding-bottom: 112rpx;
    
    .song-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 30rpx;
        margin-bottom: 20rpx;
        background: white;
        border-radius: 12rpx;
        box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);

        .item-content {
            flex: 1;
            margin-right: 20rpx;
            display: flex;
            flex-direction: column;
        }

        .song-title {
            font-size: 32rpx;
            color: #333;
            font-weight: 500;
            margin-bottom: 10rpx;
        }

        .song-desc {
            font-size: 26rpx;
            color: #666;
        }
    }
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32rpx;

  .header-title {
    font-size: 36rpx;
    font-weight: bold;
  }
}
</style>